Multiple fixes around NumericString type #256
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi AWA team !
Here at TextNow we use your repository in order to communicate with Apple and Google for our IAP.
While using this repository, we found some potentialk improvements regarding the use of
NumericString
type.We are using these fixes for a while in our Production environment and have no problem so far.
Changes:
numericString
toNumericString
: This is usually a good pattern that every field of a public struct are made of purely public types. With this, we can easily build structs containingNumericString
type in order to run tests and compare results.InApp.OriginalTransactionID
fromstring
toNumericString
: similarly toReceiptForIOS6.OriginalTransactionID
, this field is also worth usingNumericString
. This also simplifies comparing the 2 fields since they would be the same type.omitempty
to someNumericString
fields : Apple usually do not send emptyOriginalTransactionID
and theNumericString
type fails to parse empty strings. If we Marshall->Unmarshall a struct withNumericString
in it, it fails since we produce an empty string when Marshalling. An alternative would be to not fail when parsing an empty string, but I'm not sure this is a wanted change but feel free to ask me to do it !Thanks a lot for checking this PR !